package com.epam.newsmanagement.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@Entity
@NamedQueries({
	@NamedQuery(name="read_all", query ="SELECT n FROM News n ORDER BY n.date DESC"),
	@NamedQuery(name="delete", query ="DELETE FROM News n WHERE n.id in (:selectedNews)")
}) 
@Table(name="news")
public class News implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String content;
	private String brief;
	private String title;
	private Date date;
	public News(){}
	public News(int id, Date date, String title, String brief, String content){
		this.id = id;
		this.date = date;
		this.title = title;
		this.brief = brief;
		this.content = content;
	}
	@Column(name="content")
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@Column(name="brief")
	public String getBrief() {
		return brief;
	}
	public void setBrief(String brief) {
		this.brief = brief;
	}
	@Column(name="title")
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@Column(name="addDate")
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	@Id
	@SequenceGenerator(name="ID", sequenceName="NEWS_SEQ")
	@GeneratedValue(generator="ID")
	@Column(name="ID")
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
}
